<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body></body>
  <script>
    // await 表达式会暂停整个 async 函数的执行进程并出让其控制权，只有当其等待的基于 promise 的异步操作被兑现或被拒绝之后才会恢复进程

    // async function func() {
    //   console.log(1);
    //   await 2;
    //    console.log(2);
    //   await 3
    //   console.log(3);
    //   await 4
    //   console.log(4);
    // }
    // func();
    // Promise.resolve()
    //   .then(() => console.log(5))
    //   .then(() => console.log(6))
    //   .then(() => console.log(7));
    // async function fun() {
    //   return Promise.resolve(1)
    //     .then((res) => console.log(2))
    //     .then(() => console.log(3))
    //     .then(() => console.log(4));
    // }
    // fun();
    Promise.resolve()
      .then((res) => console.log(2))
      .then(() => console.log(3))
      .then(() => console.log(4));
    Promise.resolve()
      .then(() => console.log(5))
      .then(() => console.log(6))
      .then(() => console.log(7));
  </script>
</html>
